package de.szut.ita13sommerfeld.apacheanalyser.reader;

import java.io.BufferedReader;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.util.Scanner;

/**
 * @author Rene Sommerfeld
 */

public class ApacheReader extends BufferedReader {
	
	private File logfile;
	private Scanner scanner;
	
	/**
	 * @param logfile is the file that will be analyzed
	 * @throws FileNotFoundException is thrown if the file is not found
	 */
	public ApacheReader(File logfile) throws FileNotFoundException {
		super(new FileReader(logfile.getAbsoluteFile()));
		this.logfile = logfile;
		scanner = new Scanner(this);
	}

	/**
	 * @return the logfile
	 */
	public File getLogfile() {
		return logfile;
	}
	
	/**
	 * @param logfile sets the logfile that will be analyzed
	 */
	public void setLogfile(File logfile) {
		this.logfile = logfile;
	}
	
	/**
	 * 
	 * @return returns if the log has a line left
	 */
	public boolean hasNextLogLine() {
		return scanner.hasNextLine();
	}
	
	/**
	 * 
	 * @return returns the next line of the log
	 */
	public String getNextLogLine() {
		return scanner.nextLine();
	}
}
